<form action="amazon.php"  method="post" name="frmWithdraw" id="frmWithdraw" enctype="application/x-www-form-urlencoded">
  <table width="100%"  border="1" cellspacing="0" class="container">
    <tr>
      <td width="469" height="25" class="tdHeader">Referred Commission</td>
    </tr>
    <tr>
      <td height="25" class="Error"><?php if($_SESSION['order_msg']!=""){echo $_SESSION['order_msg']; $_SESSION['order_msg']="";}?></td>
    </tr>
    <tr>
      <td height="577">
	<div "style="overflow-y:scroll;"">
	<table width="100%"  border="0" cellspacing="0">      
	  <tr class="InnerHeader">    
	    <td width="10%" class="line">Sln no.</td> 
	    <td width="45%" class="line">User(Type) </td>		
	    <td width="25%" class="line">Referred Comm</td>	
	    <td></td>	
	  </tr>
      
      <?php 
	  
	  ini_set('display_errors', 1); 
	  ini_set('error_reporting', 'E_error'); 
	  $sql_shocat="SELECT sum(refer_comm) as TotalComm,b.* FROM tbl_refer_comm r left join tbl_users b ON r.refer_by_user_id = b.user_id  WHERE isPaid = '2' group BY refer_by_user_id having TotalComm>0";//limit ".$pageNumber.", ".$itemPerPage."";
	  //echo 	$sql_shocat;			 
	  $rst_comm=mysql_query($sql_shocat);
	  $row_comm=getRecordArray($rst_comm);
				 				 
				 //In this row query evy thing of user will be fetched
				 
	  $total=0;
	  if(is_array($row_comm))
	  {
	    //print_r($row_comm);
	    $counter=count($row_comm);
	    for($i=0;$i<$counter;$i++)					
	    {
	    
	      if($row_comm[$i]['user_type']==1)
		$ref_type = "Buyer";
	      else if($row_comm[$i]['user_type']==2)
		$ref_type = "Seller";		 
	      else if($row_comm[$i]['user_type']==3)
		$ref_type = "Merchant";	
	      else if($row_comm[$i]['user_type']==4)
		$ref_type = "Seller/ Buyer";
		    
	      $total=$total+$row_comm[$i]['TotalComm'];
	      $row_comm[$i]['first_name'];
					 			 
				 ?> 
	<tr>
	<td class="line"><?php echo ($i+1);?></td>					
	<td class="line"><?php echo $row_comm[$i]['first_name']." ".$row_comm[$i]['last_name'];?> (<?php echo $ref_type?>)</td>
	<td class="line">$<?php echo $row_comm[$i]['TotalComm'];?></td>
	<td class="line"><input type="hidden" name="recipient_token_arr[]" id="recipient_token_arr[]" value="<?php echo $row_comm[$i]['tokenID1'];?>"  /><input type="hidden" name="recipient_amount_arr[]" id="recipient_amount_arr[]" value="<?php echo number_format($row_comm[$i]['TotalComm'],2);?>"  /><input type="hidden" name="user_id_arr[]" id="user_id_arr[]" value="<?php echo $row_comm[$i]['user_id'];?>"  /></td>	
      				</tr><?php }
				}?>     
       </table>	
	</div>
	</td>
 </tr>
 <tr>
 <td style="text-align:right;">Total Owed so far $<?php echo $total;?>  
 <input type="submit" name="submit" id="submit" value="Pay Now" />
 </td>
 </tr>
</table>
</form>